/*
 * Copyright 2025-2026 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @author brianxiadong
 */
package org.springframework.ai.mcp.sample.server;

import org.springframework.ai.tool.annotation.Tool;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 利用OpenMeteo的免费天气API提供天气服务
 * 该API无需API密钥，可以直接使用
 */
@Service
public class QueryNoticeService {

    //生成一些实例的用户信息
    private static final List<NoticeInfo> list = List.of(
            new NoticeInfo(1, "第一次员工大会", "第一次员工大会在东大街会议室召开"),
            new NoticeInfo(2, "第二次员工大会", "第二次员工大会在东大街会议室召开"),
            new NoticeInfo(3, "第三次员工大会", "第三次员工大会在东大街会议室召开"),
            new NoticeInfo(4, "第四次员工大会", "第四次员工大会在东大街会议室召开"),
            new NoticeInfo(5, "第五次员工大会", "第五次员工大会在东大街会议室召开")
    );


    /**
     * 查询翻台宝通知
     *
     * @return 返回通知信息
     */
    @Tool(description = "查询翻台宝通知")
    public List<NoticeInfo> queryList() {
        return list;
    }


    /**
     * 查询翻台宝通知-根据通知公告名称查询
     * title 通知标题
     * @return 返回通知信息
     */
    @Tool(description = "根据通知标题查询翻台宝通知")
    public NoticeInfo queryInfo(String title) {
        for (NoticeInfo noticeInfo : list) {
            if (noticeInfo.getTitle().contains(title)) {
                return noticeInfo;
            }
        }
        return null;
    }

}